class ErrorLogger
  include Sidekiq::Worker
  sidekiq_options :queue => :monitor


  SERVER_ADDRESS = "http://monitor.quicksteps.cn"
  # SERVER_ADDRESS = "http://localhost:3000"

  def perform(request_path, params, user_id, timestamp, cause, trace)
    application = Rails.application.class.parent_name
    log(application, Rails.env, request_path, params, user_id, timestamp, cause, trace)
  end


  def log(application, environment, request_path, params, user_id, timestamp, cause, trace)
  
    RestClient.post("#{SERVER_ADDRESS}/server_logs", application: application, 
                                              environment: environment,
                                              request_path: request_path,
                                              params: params,
                                              user_id: user_id,
                                              timestamp: timestamp,
                                              cause: cause,
                                              trace: trace)
  end
end
